]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
switcherPopup: Use local variable for index in scrolling functions
authorJonas Dreßler <verdre@v0yd.nl>
Wed, 25 Apr 2018 21:24:05 +0000 (23:24 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 26 Feb 2020 22:46:51 +0000 (22:46 +0000)
Make sure the index that's being scrolled to doesn't change while the
scrolling animation is running by using an argument instead of the
this._highlighed class scope variable.

This fixes wrongly shown arrows when selecting new elements faster than
the scrolling animation takes for one index. The check run to disable
the arrow might be checking against a newer index than the one at the
start of the animation which results in the arrow not getting hidden
even if no more scrolling is possible.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/167

js/ui/switcherPopup.js

index d026453ca3cf47bf6233dcd4afc2b5db9232da48..16aa24c649986bcdabc1c62a90a561b339daedbf 100644 (file)
@@ -467,17 +467,17 @@ var SwitcherList = GObject.registerClass({
         let [result_, posX, posY_] = this.transform_stage_point(absItemX, 0);
         let [containerWidth] = this.get_transformed_size();
         if (posX + this._items[index].get_width() > containerWidth)
-            this._scrollToRight();
+            this._scrollToRight(index);
         else if (this._items[index].allocation.x1 - value < 0)
-            this._scrollToLeft();
+            this._scrollToLeft(index);
 
     }
 
-    _scrollToLeft() {
+    _scrollToLeft(index) {
         let adjustment = this._scrollView.hscroll.adjustment;
         let [value, lower_, upper, stepIncrement_, pageIncrement_, pageSize] = adjustment.get_values();
 
-        let item = this._items[this._highlighted];
+        let item = this._items[index];
 
         if (item.allocation.x1 < value)
             value = Math.min(0, item.allocation.x1);
@@ -489,18 +489,18 @@ var SwitcherList = GObject.registerClass({
             progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD,
             duration: POPUP_SCROLL_TIME,
             onComplete: () => {
-                if (this._highlighted == 0)
+                if (index === 0)
                     this._scrollableLeft = false;
                 this.queue_relayout();
             },
         });
     }
 
-    _scrollToRight() {
+    _scrollToRight(index) {
         let adjustment = this._scrollView.hscroll.adjustment;
         let [value, lower_, upper, stepIncrement_, pageIncrement_, pageSize] = adjustment.get_values();
 
-        let item = this._items[this._highlighted];
+        let item = this._items[index];
 
         if (item.allocation.x1 < value)
             value = Math.max(0, item.allocation.x1);
@@ -512,7 +512,7 @@ var SwitcherList = GObject.registerClass({
             progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD,
             duration: POPUP_SCROLL_TIME,
             onComplete: () => {
-                if (this._highlighted == this._items.length - 1)
+                if (index === this._items.length - 1)
                     this._scrollableRight = false;
                 this.queue_relayout();
             },